<?php

$HTMLstr .= '<div class="body">
    <div class="findOne">
    <div class="findOneInside">';

if (!empty($this->message)) {
    $HTMLstr .= '<div class="head">
        '.$this->message.'
        </div>';
}

if (empty($this->post['name'])) {
    $this->post['name'] = null;
}
if (empty($this->post['sex'])) {
    $this->post['sex'] = null;
}
if (empty($this->post['fromage'])) {
    $this->post['fromage'] = null;
}
if (empty($this->post['toage'])) {
    $this->post['toage'] = null;
}

$HTMLstr .= '<form action="?controller=news&action=filter" method="post">
        
        <div class="head">
        Имя пользователя или часть его имени:
        </div>
        <div class="fetchallOne" id="frame">
        <textarea cols="30" rows="1" name="name">'. $this->post['name'] .'</textarea><br>
        </div>

        <div class="head">
        Возраст:
        от <select name="fromage">
        <option value="0">Не важно</option>';

for ($i=16;$i<61;$i++) {
    $HTMLstr .= '<option value="'. $i .'"';
    if($this->post['fromage'] == $i) {
        $HTMLstr .= 'SELECTED';
    }
    $HTMLstr .= '>'. $i .'</option>';
}

$HTMLstr .= '</select>
    до <select name="toage">
    <option value="0">Не важно</option>';
for ($i=16;$i<61;$i++) { //TODO: блокирвоать значения "до" если они меньше "от"
    $HTMLstr .= '<option value="'. $i .'">'. $i .'</option>';
}
$HTMLstr .= '</select></div>

        <div class="head">Пол:
        <input type="radio" name="sex" value="m"';
if('m' == $this->post['sex']) {
    $HTMLstr .= 'CHECKED';
}
$HTMLstr .= '> Мужской
        <input type="radio" name="sex" value="w"';
if('w' == $this->post['sex']) {
    $HTMLstr .= 'CHECKED';
}
$HTMLstr .= '> Женский
        </div>
        <div class="fetchallOne" id="frame">
        <input type="submit" value="Искать">
        </div>
        </form>
        </div>
        </div>
        </div>';